<template>
  <div class="container">
    <el-dialog
      title="税票详情"
      :visible.sync="taxParticularsDialogs.centerDialogVisible"
      @open="getData"
      center
    >
      <el-table :data="tableData" border style="width: 100%" empty-text="暂无数据">
        <el-table-column prop="invoice_title" label="抬头" align="center"></el-table-column>
        <el-table-column prop="uniform_number" label="税号" align="center"></el-table-column>
        <el-table-column prop="amount" label="金额" align="center"></el-table-column>
        <el-table-column prop="created_at" label="创建时间" align="center"></el-table-column>
        <el-table-column prop="updated_at" label="更新时间" align="center"></el-table-column>
        <el-table-column label="操作" width="150" align="center">
          <template slot-scope="scope">
            <el-button type="info" size="mini" icon="el-icon-info" @click=" particulars(scope)">税票明细</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- <div class="pagination">
        <el-pagination
          @size-change="handleCurrentChange"
          @current-change="handleSizeChange"
          :current-page.sync="pageData.page"
          :page-sizes="pageData.pageSizes"
          :page-size="pageData.pageSize"
          :layout="pageData.layout"
          :total="pageData.total"
        ></el-pagination>
      </div>-->
      <el-dialog
        width="50%"
        title="税票明细"
        @open="getDatas"
        :visible.sync="taxParticularsDialog.innerVisible"
         center
        append-to-body
      >
        <div slot="footer" class="dialog-footer">
          <el-table :data="tableDatas" border style="width: 100%" empty-text="暂无数据">
            <el-table-column prop="goods_name" label="商品名称" align="center"></el-table-column>
            <el-table-column prop="goods_price" label="商品价格" align="center"></el-table-column>
            <el-table-column prop="goods_num" label="商品数量" align="center"></el-table-column>
            <el-table-column prop="amount" label="商品总价格" align="center"></el-table-column>

          </el-table>
          <el-button type="primary" @click="confirms">确 定</el-button>
        </div>
      </el-dialog>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getInvoiceList,getInvoiceDetail } from "@/api/supplier/supplierList";
export default {
  props: {
    taxParticularsDialogs: Object
  },
  data() {
    return {
      tableData: [],
      tableDatas:[],
      taxParticularsDialog:{
      innerVisible: false,
      id:''
      },
      // pageData: {
      //   pageSizes: [10, 20],
      //   pageSize: 10,
      //   page: 1,
      //   total: null,
      //   layout: "total, sizes, prev, pager, next, jumper"
      // }
    };
  },
  methods: {
    confirms() {
      this.taxParticularsDialog.innerVisible = false;
    },
    confirm() {
      this.taxParticularsDialogs.centerDialogVisible = false;
    },
    getData() {
      let data = {
        // limit: this.pageData.pageSize,
        // page: this.pageData.page,
        supplier_id: this.taxParticularsDialogs.id
      };
      getInvoiceList(data).then(res => {
        if (res.code == 0) {
          this.tableData = res.data;
          // this.pageData.page = res.data.current_page;
          //   this.pageData.pagesize = res.data.per_page;
          //   this.pageData.total = res.data.total;
        }
      });
    },
    getDatas(){
      let data = {
        id: this.taxParticularsDialog.id
      }
      getInvoiceDetail(data).then(res =>{
        this.tableDatas = res.data
      })
    },
    // 税票明细
    particulars(scope) {
      this.taxParticularsDialog.id = scope.row.id;
      this.taxParticularsDialog.innerVisible = true;
    },
    //每页多少条
    handleCurrentChange(val) {
      this.pageData.page = 1;
      this.pageData.pageSize = val;
      this.getData();
    },
    //选取页数
    handleSizeChange(page) {
      this.pageData.page = page;
      this.getData();
    }
  }
};
</script>
<style scoped>
.pagination {
  text-align: right;
  padding: 10px;
}
</style>